package com.edu.ujn.myh.utils;
/**
 * 
 * @作者 马永华
 * @日期 2010-4-28上午10:22:34
 * @版本 1.0.0
 * @说明 分页
 */
@SuppressWarnings("unused")
public class Pager {
	
	private int currentPage=1;	//当前页
	private int pageSize = 5;	//每页大小；
	private int totalSize = 1;	//总记录数
	private int totalPage;	//总页数
	
	private boolean hasFirst;
	private boolean hasPrevious;
	private boolean hasNext;
	private boolean hasLast;
	
	public Pager(){}
	
	public Pager(int currentPage, int totalSize){
		this.currentPage = currentPage;
		this.totalSize = totalSize;
	}
	
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
//		如果当前页面小于1，则把当前页设为一，如果当前页号大于总页数，则把当前页号设为总页数
		this.currentPage = currentPage < 1 ? 1 : currentPage > totalPage? totalPage : currentPage;
		
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalSize() {
		return totalSize;
	}
	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
//		如果总页数等于0，则把总页数设为1
		this.totalPage = totalPage ==0? 1 : totalPage ;
	}
	public boolean isHasFirst() {
		if(currentPage==1){
			return false;
		}
		return true;
	}
	public void setHasFirst(boolean hasFirst) {
		this.hasFirst = hasFirst;
	}
	public boolean isHasPrevious() {
		if(isHasFirst()){
			return true;
		}
		return false;
	}
	public void setHasPrevious(boolean hasPrevious) {
		this.hasPrevious = hasPrevious;
	}
	public boolean isHasNext() {
		if(isHasLast()){
			return true;
		}
		return false;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public boolean isHasLast() {
		if(currentPage==getTotalPage()){
			return false;
		}
		return true;
	}
	public void setHasLast(boolean hasLast) {
		this.hasLast = hasLast;
	}
	
}
